from PrefOp import PrefOp
from cfg import *


class LoginWeb(PrefOp):
    # ROBOT_LIBRARY_SCOPE = 'Global'

    def loginWebsite(self, username, pwd):
        # 打开登录页面
        PrefOp.shared_wd.get(PrefUrl)
        # 填写用户名
        PrefOp.shared_wd.find_element_by_name('username').send_keys(username)
        # 填写密码
        PrefOp.shared_wd.find_element_by_name('password').send_keys(pwd)
        # 点击登录按钮执行登录操作
        PrefOp.shared_wd.find_element_by_css_selector('#submit').click()

    # def should_contain_text(self, actual, expect):
    #     if actual not in expect:
    #         raise Exception('the actual result does not match the expect!')

    # def check_login_result(self):
    #     # 获取登录界面欢迎语
    #     welcome = PrefOp.shared_wd.find_element_by_css_selector('#10000000')
    #     self.should_contain_text(loginInfo['username'], welcome)




if __name__ == '__main__':
    lw = LoginWeb()
    lw.openBrowser()
    lw.loginWebsite(loginInfo['username'], loginInfo['password'])
    # lw.check_login_result()
    lw.closeBrowser()
